<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!--  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>-->
    <script src="vue.js"></script>
</head>
<body>

<div id="app">
    <input type="button" value="-1" @click="methodSub($event)">
    {{count}}
    <input type="button" value="+1" v-on:click="methodAdd($event)">
</div>
</body>
<script>
    let vm = new Vue({
        el:"#app",
        data() {
            return {
                count:0
            }
        },
        methods: {
            //e参数，就是$event
            methodSub(e){
                console.log(e);
                this.count--;
                this.totalprice = this.price * this.count;
            },
            methodAdd(e){
                console.log(e);
                this.count++;
                this.totalprice = this.price * this.count;
            },
            updateValue(e){
                console.log(e);
                this.name = e;
            }
        },
    });
</script>
